﻿#region Copyright

// All Material Copyright © 2010 Dynamic Concepts Development Corp., All Rights Reserved.
//      Portions Copyright © 1984-2009 Dynamic Concepts Development Corp., All Rights Reserved.
// For further information please contact: SoftwareSupport@dynconcepts.com
// Dynamic Concepts Development Corp.  311 W 57th St. Suite #422, New York, NY 10019

#endregion

#region Using References

using System;
using System.Windows.Threading;

#endregion

namespace DynConDevCorp.OpenArch.SupportLibrary.ParallelExecution.Events
{
    public interface IParallelEvent
    {
        #region Public Properies and Indexers

        Type ArgumentType { get; }
        ParallelEventDispatchMode DispatchMode { get; set; }
        Dispatcher EventCreatorDispatcher { get; }

        #endregion

        #region Public Methods

        void TargetCompleted(IParallelEventTarget target, object sender, EventArgs args);
        void WaitForIdle();

        #endregion
    }

    public interface IParallelEvent<TARGS> : IParallelEvent
        where TARGS : EventArgs
    {
        #region Public Methods

        IParallelEventTarget Add(ParallelEventHandler<TARGS> theHandler);
        IParallelEventTarget Add(ParallelEventHandler<TARGS> theHandler, ParallelEventHandler<TARGS> completionHandler);
        IParallelEventTarget Add(ParallelEventHandler<TARGS> theHandler, ParallelEventHandler<TARGS> completionHandler, string name);
        IParallelEventTarget Add(ParallelEventHandler<TARGS> theHandler, string name);
        IParallelEventTarget Add(EventHandler<TARGS> internalHandler);
        IParallelEventTarget Add(EventHandler<TARGS> internalHandler, string name);

        void Execute(object sender, TARGS args);
        void Execute(object sender, TARGS args, ParallelEventHandler<TARGS> completionHandler);
        void Execute(object sender, TARGS args, EventHandler<TARGS> completionHandler);
        void ExecuteImpl(object sender, TARGS args, ParallelEventHandler<TARGS> completionHandler);
        void Remove(ParallelEventHandler<TARGS> theHandler);
        void Remove(EventHandler<TARGS> theHandler);

        #endregion
    }
}